package org.example.cake.service.impl;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.example.cake.entity.Carousel;
import org.example.cake.mapper.CarouselMapper;
import org.example.cake.service.CarouselService;

import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService{

    @Resource
    private CarouselMapper carouselMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return carouselMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Carousel record) {
        return carouselMapper.insert(record);
    }

    @Override
    public int insertSelective(Carousel record) {
        return carouselMapper.insertSelective(record);
    }

    @Override
    public Carousel selectByPrimaryKey(Integer id) {
        return carouselMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Carousel record) {
        return carouselMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Carousel record) {
        return carouselMapper.updateByPrimaryKey(record);
    }

    // 查询所有轮播图
    @Override
    public List<Carousel> getCarouselList() {
        return carouselMapper.getCarouselList();
    }

    /**
     * //后台轮播图查询
     * @author 徐
     * @param title 轮播图标题
     * @date 2025-07-28
     * @return 轮播图集合
     */
    @Override
    public List<Carousel> selectCarouselPageEnd(String title) {
        return carouselMapper.selectCarouselPageEnd(title);
    }

    /**
     * //后台轮播图删除（根据id删除）
     * @author 徐
     * @param id 轮播图id
     * @date 2025-07-28
     * @return 轮播图id
     */
    @Override
    public String deleteCarouselIdEnd(Integer id) {
        return carouselMapper.deleteCarouselIdEnd(id)>0?"删除成功":"删除失败";
    }

    /**
     * //后台轮播图修改状态（根据id修改）
     * @author 徐
     * @param id 轮播图id
     * @param status 轮播图状态
     * @date 2025-07-28
     * @return 受影响的行数
     */
    @Override
    public String updateCarouselStatusEnd(Integer id, Integer status) {
        return carouselMapper.updateCarouselStatusEnd(id, status)>0?"修改成功":"修改失败";
    }

    /**
     * //新增后台轮播图信息
     * @author 徐
     * @param carousel 轮播图对象
     * @date 2025-07-28
     * @return 受影响的行数
     */
    @Override
    public String insertCarouselEnd(Carousel carousel) {
        return carouselMapper.insertCarouselEnd(carousel)>0?"新增成功":"新增失败";
    }

    /**
     * //修改后台轮播图信息
     * @author 徐
     * @param carousel 轮播图对象
     * @date 2025-07-28
     * @return 受影响的行数
     */
    @Override
    public String updateCarouselEnd(Carousel carousel) {
        return carouselMapper.updateCarouselEnd(carousel)>0?"修改成功":"修改失败";
    }

    /**
     * //修改轮播图图片
     * @author 徐
     * @param carousel 轮播图对象
     * @date 2025-07-28
     * @return 受影响的行数
     */
    @Override
    public int updateCarouselImgEnd(Carousel carousel) {
        return carouselMapper.updateCarouselImgEnd(carousel);
    }

    /**
     * //批量新增轮播图图片
     * @author 徐
     * @param carouselList 轮播图图片集合
     * @date 2025-07-28
     * @return 受影响的行数
     */
    @Override
    public int addCarouselImgEnd(List<Carousel> carouselList) {
        return carouselMapper.addCarouselImgEnd(carouselList);
    }


    //存入minio的方法
    @Override
    public void sava(Carousel carousel) {

    }

    /**
     * //后台根据id查询轮播图是否存在
     * @author 徐
     * @param id 轮播图id
     * @date 2025-08-04
     * @return 受影响行数
     */
    @Override
    public Carousel selectById(Integer id) {
        return carouselMapper.selectById(id);
    }


}
